﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Drawing;
using System.Drawing.Imaging;

namespace FlickrDownloadr
{
    public class NavigationControl : Panel
    {
        private Navigation _navigation = Navigation.Left;

        public Navigation Navigation
        {
            get { return _navigation; }
            set {
                _navigation = value;

                if (!DesignMode)
                {
                    UpdateBackground();
                }
            }
        }

        private void UpdateBackground()
        {
            if (Enabled)
            {
                if (Navigation == Navigation.Left)
                    BackgroundImage = Properties.Resources.GoRtlHS;
                else
                    BackgroundImage = Properties.Resources.GoLtrHS;
            }
            else
            {
                if (Navigation == Navigation.Left)
                    BackgroundImage = Properties.Resources.GoRtlHS_Disabled;
                else
                    BackgroundImage = Properties.Resources.GoLtrHS_Disabled;
            }

            Invalidate();
        }

        public NavigationControl()
        {
            BackgroundImageLayout = ImageLayout.None;
        }

        //protected override void OnMouseEnter(EventArgs e)
        //{
        //    base.OnMouseEnter(e);

        //    if (!Enabled)
        //        return;

        //    if (Navigation == Navigation.Left)
        //        BackgroundImage = Properties.Resources.GoRtlHS_Hover;
        //    else
        //        BackgroundImage = Properties.Resources.GoLtrHS_Hover;

        //    Invalidate();
        //}

        //protected override void OnMouseLeave(EventArgs e)
        //{
        //    base.OnMouseLeave(e);

        //    if (!Enabled)
        //        return;

        //    if (Navigation == Navigation.Left)
        //        BackgroundImage = Properties.Resources.GoRtlHS;
        //    else
        //        BackgroundImage = Properties.Resources.GoLtrHS;

        //    Invalidate();
        //}

        protected override void OnEnabledChanged(EventArgs e)
        {
            base.OnEnabledChanged(e);

            UpdateBackground();
        }
    }

    public enum Navigation
    {
        Left,
        Right
    }
}
